public class MutualFundOrder extends AbstractOrder {

	public MutualFundOrder() {
		setInitializedState(new OrderInitializedState(this));
		setActiveState(new OrderActiveState(this));
		setPartialState(new OrderPartialState(this));
		setClosedState(new OrderClosedState(this));
	}

	@Override
	public void createOrder(int orderId, OrderCategory orderCategory,
			int accountId, int portfolioId) {

		setAccountId(accountId);
		setOrderId(orderId);
		setOrderCategory(orderCategory);
		setPortfolioId(portfolioId);

		MutualFundRepository mutualFundRepository = MutualFundRepository
				.getMutualFundRepository();
		MutualFund mutualFund = mutualFundRepository
				.getMutualFund(getMutualFundId());
		if ((mutualFund != null)) {
			setMutualFundId(getMutualFundId());
			double mutualFundPrice = mutualFund.getMutualFundPrice();
			setQuantity(getQuantity());
			setSecurityPrice(mutualFundPrice);

			double orderPrice = getQuantity() * mutualFundPrice;
			setOrderPrice(orderPrice);
		} else {
			System.out.println("Mutual Fund does not exists! ");
		}
	}

	@Override
	public void display() {
		System.out.println("\nOrder Id: " + getOrderId());
		System.out.println("Mutual Fund Id: " + getMutualFundId());
		System.out.println("Order Category: " + getOrderCategory());
		System.out.println("Quantity: " + getQuantity());
	}

	@Override
	public void updateOrder(StockValueObserver buyer,
			StockValueObserver seller, int matchedQuantity) {
		System.out.println("Update Mutual Fund Orders! ");
	}

	@Override
	public void setState(OrderState orderState) {
		setOrderState(orderState);
	}

	@Override
	public void initializeOrder() {
		if (getOrderState() == null) {
			getInitializedState().initializeOrder();
		} else {
			getOrderState().initializeOrder();
		}
	}

	@Override
	public void activeOrder() {
		getOrderState().activeOrder();
	}

	@Override
	public void partialOrder() {
		getOrderState().partialOrder();
	}

	@Override
	public void closeOrder(boolean isOrderFulfilled) {
		getOrderState().closeOrder(isOrderFulfilled);
	}

	@Override
	public OrderState getOrderInitializedState() {
		return getInitializedState();
	}

	@Override
	public OrderState getOrderActiveState() {
		return getActiveState();
	}

	@Override
	public OrderState getOrderClosedState() {
		return getClosedState();
	}

	@Override
	public OrderState getOrderPartialState() {
		return getPartialState();
	}

	@Override
	public AbstractOrder newStockOrder(AbstractOrder newOrder) {
		return null;
	}

}
